// string 转成 object对象
// /?username=zhangsan&pwd=123
// let str = "/?username=zhangsan&pwd=123";
function s2o(str){
    let arr = str.split('?');
   // console.log(arr);  //[ '/', 'username=zhangsan&pwd=123' ]
    let qs = arr[1];
  //  console.log(qs);   // username=zhangsan&pwd=123
   let newarr =  qs.split('&');
  // console.log(newarr);   // [ 'username=zhangsan', 'pwd=123' ]
  let obj = {};
   newarr.forEach(item=>{
    let line = item.split('=');
    // console.log(line); //[ 'username', 'zhangsan' ] [ 'pwd', '123' ]
    obj[line[0]] = line[1];
   })
  // console.log(obj);  //{ username: 'zhangsan', pwd: '123' }
   return obj;
}
// s2o(str);
module.exports = s2o;